package com.project.drugs;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;


public class Login {
	private String admin="123";
	private String password="123";
	public Login() {
		final ExtendsJFrame jf = new ExtendsJFrame("登录",400,300);
		jf.setLayout(new GridLayout(7,1));

		JPanel jp1 = new JPanel();
		JLabel JLtitle = new JLabel("医药仓库管理系统");
		JLtitle.setFont(new Font("宋体",Font.BOLD, 20));
		jp1.add(JLtitle);
		jf.add(jp1);

		
		JPanel jp2 = new JPanel();
		jf.add(jp2);
		
		
		JPanel jp3 = new JPanel();
		JLabel JLadmin = new JLabel("用户名");
		jp3.add(JLadmin);
		final JTextField JTadmin = new JTextField(13);
		jp3.add(JTadmin);
		jf.add(jp3);


		JPanel jp4 = new JPanel();
		JLabel JLpassword = new JLabel("密    码");
		jp4.add(JLpassword);
		final JPasswordField JPpassword=new JPasswordField(13);
		jp4.add(JPpassword);
		jf.add(jp4);

		
		JPanel jp6 = new JPanel();
		jf.add(jp6);
		
		JPanel jp5 = new JPanel();
		JButton jb1 = new JButton("登录");
		jb1.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				if(JTadmin.getText().equals(admin)&&JPpassword.getText().equals(password)) {
					jf.dispose();
					new MenuMax();
				}
				else {
					JOptionPane.showMessageDialog(null,"用户名或密码错误！","错误 ",0);
					jf.dispose();
					new Login();
				}
			}
		});
		jp5.add(jb1);
		JButton jb2 = new JButton("取消");
		jb2.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				System.exit(0);
			}
		});
		jp5.add(jb2);
		jf.add(jp5);

	
		
		JPanel jp7 = new JPanel();
		jf.add(jp7);
		
	    jf.setVisible(true);
		
	}

	
	
	
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		//new Login();
	}

}
